package com.iot.inclinometer.util;

import java.util.Map;

/**
 * @Author: Song Yu
 * @Date: 2021/4/13 0013 13:35
 */
public class SQLUtil {
    public static String getBaseQuerySQL(String tableName,Object queryEntity){
        StringBuffer sqlString = new StringBuffer("select * from "+tableName+" where 1=1");
        Map<String,Object> queryMap = BeanUtil.ConvertObjToMap(queryEntity);
        for(String key:queryMap.keySet()){
            sqlString.append(" and ");
            sqlString.append(key);
            sqlString.append(" = '");
            sqlString.append(queryMap.get(key));
            sqlString.append("'");
        }
        return sqlString.toString();
    }
}
